﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;

namespace ERModelData
{
    public partial class General : Form
    {
        DiagrammEditor editor;
        ToolStrip menu;
        Diagramm diagramm;
        TableLayoutPanel layout;
        public General()
        {
            diagramm = new Diagramm();
            List<Atribute> l = new List<Atribute>();
            l.Add(new Atribute("atribut1", true));
            l.Add(new Atribute("atribut2", false));
            EssenceVisuality v1 = new EssenceVisuality(new System.Drawing.Point(10, 10), new System.Drawing.Size(100, 100));
            EssenceVisuality v2 = new EssenceVisuality(new System.Drawing.Point(120, 10), new System.Drawing.Size(100, 100));
            Essence e1 = new Essence("Essence1", true, l);e1.visuality = v1;
            Essence e2 = new Essence("Essence2", false, l);e2.visuality = v2;
            diagramm.essences.Add(e1);
            diagramm.essences.Add(e2);
            menu = new ToolStrip();
            ToolStripButton bCreateLink = new ToolStripButton("Создать связь");
            bCreateLink.Click += new EventHandler(CreateLink);
            menu.Items.Add(bCreateLink);
            layout = new TableLayoutPanel();
            layout.Dock = DockStyle.Fill;
            layout.RowCount = 2;
            layout.ColumnCount = 1;
            layout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
            layout.RowStyles.Add(new RowStyle(SizeType.Absolute, menu.Size.Height));
            layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            editor = new DiagrammEditor(diagramm);
            editor.Dock = DockStyle.Fill;
            layout.Controls.Add(menu, 0, 0);
            layout.Controls.Add(editor, 0, 1);
            this.Controls.Add(layout);
            
        }

        void CreateLink(object sender, EventArgs e)
        {
            editor.StartPaintLink();
        }
    }
}
